﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ObjectSearch.Configuration
{
    public class FieldMetaData
    {
        /// <summary>
        /// A private field used to hold the value for FieldName property.
        /// </summary>
        private string _FieldName;

        /// <summary>
        /// Gets or sets the name of the field that will be stored in the index.
        /// </summary>
        public string FieldName
        {
            get
            {
                return _FieldName;
            }
            set
            {
                _FieldName = value;
            }
        }

        /// <summary>
        /// A private field used to hold the value for PropertyName property.
        /// </summary>
        private string _MemberName;

        /// <summary>
        /// Gets or sets the name of the property or field member in the class, whose value you would like to index.
        /// </summary>
        public string MemberName
        {
            get
            {
                return _MemberName;
            }
            set
            {
                _MemberName = value;
            }
        }

        /// <summary>
        /// A private field used to hold the value for IndexOptions property.
        /// </summary>
        private IndexOptions _IndexOptions;

        /// <summary>
        /// Gets or sets how a field should be indexed.
        /// </summary>
        public IndexOptions IndexOptions
        {
            get
            {
                return _IndexOptions;
            }
            set
            {
                _IndexOptions = value;
            }
        }

        /// <summary>
        /// A private field used to hold the value for StorageOptions property.
        /// </summary>
        private StorageOptions _StorageOptions;

        /// <summary>
        /// Gets or sets how the field should be stored.
        /// </summary>
        public StorageOptions StorageOptions
        {
            get
            {
                return _StorageOptions;
            }
            set
            {
                _StorageOptions = value;
            }
        }

        /// <summary>
        /// A private field used to hold the value for TermVectorOptions property.
        /// </summary>
        private TermVectorOptions _TermVectorOptions;

        /// <summary>
        /// Gets or sets how a field should have term vectors.
        /// </summary>
        public TermVectorOptions TermVectorOptions
        {
            get
            {
                return _TermVectorOptions;
            }
            set
            {
                _TermVectorOptions = value;
            }
        }

        /// <summary>
        /// A private field used to hold the value for Boost property.
        /// </summary>
        private float _Boost = 1.0f;

        /// <summary>
        /// <para>
        /// Gets or sets the boost factor for hits for this field.
        /// This value will bemultiplied into the score of all hits on this this field of this
        /// document.
        /// </para>
        /// <para>
        /// The default value is 1.0.
        /// </para>
        /// <para>
        /// Note: this value is not stored directly with the document in the index.
        /// Documents returned from IndexReader and
        /// Hits.Doc(int) may thus not have the same value present as when
        /// this field was indexed.
        /// </para>
        /// </summary>
        public float Boost
        {
            get
            {
                return _Boost;
            }
            set
            {
                _Boost = value;
            }
        }

        /// <summary>
        /// A private field used to hold the value for SortingOptions property.
        /// </summary>
        private SortOptions _SortingOptions;

        /// <summary>
        /// Gets or sets the default sorting options when querying the index.
        /// </summary>
        public SortOptions SortingOptions
        {
            get
            {
                return _SortingOptions;
            }
            set
            {
                _SortingOptions = value;
            }
        }

        /// <summary>
        /// A private field used to hold the value for IsDefaultSearchField property.
        /// </summary>
        private bool _IsDefaultSearchField;

        /// <summary>
        /// Gets or sets if set, this will be the default field to use when searching. Only one field member should define a default search field per object configuration.
        /// </summary>
        public bool IsDefaultSearchField
        {
            get
            {
                return _IsDefaultSearchField;
            }
            set
            {
                _IsDefaultSearchField = value;
            }
        }

        /// <summary>
        /// A private field used to hold the value for IsUniqueKey property.
        /// </summary>
        private bool _IsUniqueKey;

        /// <summary>
        /// Gets or sets determins if this field is the unique key for the document. 
        /// Each document should have only a unique key which is used to update and delete values from the full text index.
        /// </summary>
        public bool IsUniqueKey
        {
            get
            {
                return _IsUniqueKey;
            }
            set
            {
                _IsUniqueKey = value;
            }
        }

        public override string ToString()
        {
            return "Field: " + this.MemberName + " / " + this.FieldName;
        }
    }
}
